home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume16 / conf2 / part03 < prev    next >
Encoding:
Internet Message Format  |  1988-09-14  |  28.8 KB

  1. Subject:  v16i003:  Multi-user conference system, Part03/05
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Keith Gabryelski <ucsd!elgar!ag>
  7. Posting-number: Volume 16, Issue 3
  8. Archive-name: conf2/part03
  9.  
  10. #! /bin/sh
  11. # This is a shell archive, meaning:
  12. # 1. Remove everything above the #! /bin/sh line.
  13. # 2. Save the resulting text in a file.
  14. # 3. Execute the file with /bin/sh (not csh) to create the files:
  15. #    confprnt.c
  16. #    confrots.c
  17. #    confrw.c
  18. export PATH; PATH=/bin:$PATH
  19. if test -f 'confprnt.c'
  20. then
  21.     echo shar: will not over-write existing file "'confprnt.c'"
  22. else
  23. cat << \SHAR_EOF > 'confprnt.c'
  24. #include "conf.h"
  25.  
  26. jmp_buf glenv, cvenv;
  27.  
  28. #define    BACKCHAR() {if (expand8bit && !isascii(*(lp-1)))         \
  29.             (void)fputs("\b \b", stdout);              \
  30.             if (expandctrl && iscntrl(toascii(*(lp-1)))) \
  31.             (void)fputs("\b \b", stdout);              \
  32.             (void)fputs("\b \b", stdout); --lp;}
  33.  
  34. unsigned linelen, col = 0;
  35.  
  36. my_intr(sig)
  37. int sig;
  38. {
  39.     longjmp(glenv, sig);
  40. }
  41.  
  42. save_intr(sig)
  43. int sig;
  44. {
  45.     longjmp(cvenv, sig);
  46. }
  47.  
  48. fputchar(c)
  49. int c;
  50. {
  51.     (void)putchar(c);
  52. }
  53.  
  54. printmess(stream, constr, usr, tty, mess, length)
  55. char *constr, *usr, *tty, *mess;
  56. unsigned length;
  57. FILE *stream;
  58. {
  59.     register char *ptr = constr;
  60.     register int c;
  61.  
  62.     while (c = *ptr++)
  63.     {
  64.     switch(c)
  65.     {
  66.         case '%':
  67.         switch(c = *ptr++)
  68.         {
  69.             case 'T':
  70.             visprnt(cuser.cu_tty, stream);
  71.             break;
  72.  
  73.             case 't':
  74.             visprnt(tty, stream);
  75.             break;
  76.  
  77.             case 'N':
  78.             visprnt(cuser.cu_cname, stream);
  79.             break;
  80.  
  81.             case 'n':
  82.             visprnt(usr, stream);
  83.             break;
  84.  
  85.             case 'm':
  86.             messptr(mess, stream, length);
  87.             break;
  88.  
  89.             case '\0':
  90.             (void)putc('%', stream);
  91.             --ptr;
  92.             break;
  93.  
  94.             default:
  95.             (void)putc('%', stream);
  96.             case '%':
  97.             (void)putc(c, stream);
  98.             break;
  99.         }
  100.         break;
  101.  
  102.         default:
  103.         (void)putc(c, stream);
  104.         break;
  105.     }
  106.     }
  107.  
  108.     (void)fflush(stream);
  109. }
  110.  
  111. messptr(mess, stream, length)
  112. char *mess;
  113. unsigned length;
  114. FILE *stream;
  115. {
  116.     register char *ptr = mess;
  117.  
  118.     while (length--)
  119.     dispchar(*ptr++, stream, NOVIS);
  120.  
  121.     (void)fflush(stream);
  122. }
  123.  
  124. visprnt(mess, stream)
  125. char *mess;
  126. FILE *stream;
  127. {
  128.     register char *ptr = mess;
  129.  
  130.     while (*ptr)
  131.     dispchar(*ptr++, stream, VIS);
  132.  
  133.     (void)fflush(stream);
  134. }
  135.  
  136. vislen(mess)
  137. register char *mess;
  138. {
  139.     register int length = 0;
  140.  
  141.     while (*mess)
  142.     {
  143.     if (!isascii(*mess) && expand8bit)
  144.         length += 2;
  145.     if (iscntrl(*mess) && expandctrl)
  146.         ++length;
  147.     ++length;
  148.     ++mess;
  149.     }
  150.  
  151.     return length;
  152. }
  153.  
  154. dispchar(c, stream, flag)
  155. int c;
  156. FILE *stream;
  157. int flag;
  158. {
  159.     int wasmeta = FALSE;
  160.  
  161.     if (!isascii(c) && !expand8bit)
  162.     {
  163.     (void)putc(c, stream);
  164.     return;
  165.     }
  166.  
  167.     if (!isascii(c))
  168.     {
  169.     (void)putc('~', stream);
  170.     c = toascii(c);
  171.     wasmeta = TRUE;
  172.     }
  173.  
  174.     if (iscntrl(c) && expandctrl)
  175.     {
  176.     switch (c)
  177.     {
  178.         case DEL:
  179.         (void)fputs("^?", stream);
  180.         break;
  181.  
  182.         case '\n':
  183.         case TAB:
  184.         if (!wasmeta && !(flag&VIS))
  185.         {
  186.             (void)putc(c, stream);
  187.             break;
  188.         }
  189.  
  190.         default:
  191.         (void)putc('^', stream);
  192.         (void)putc(c|'@', stream);
  193.         break;
  194.     }
  195.     }
  196.     else
  197.     (void)putc(c, stream);
  198. }
  199.  
  200. char *
  201. getline()
  202. {
  203.     int c;
  204.     char *line = mymalloc(PAGESIZ);
  205.     int tmplen, len = PAGESIZ;
  206.     char *lp = line;
  207.  
  208.     if (c = setjmp(glenv))
  209.     {
  210.     (void)alarm(0);
  211.     (void)signal(SIGALRM, my_intr);
  212.     (void)signal(SIGINT, SIG_IGN);
  213.  
  214.     switch(c)
  215.     {
  216.         case SIGINT:
  217.         dispchar(ichar, stdout, NOVIS);
  218.         (void)putchar('\n');
  219.         break;
  220.     }
  221.  
  222.     free(line);
  223.     return NULL;
  224.     }
  225.  
  226.     (void)signal(SIGALRM, my_intr);
  227.     (void)signal(SIGINT, my_intr);
  228.  
  229.     (void)alarm(1);
  230.     read(0, lp, 1);
  231.     (void)alarm(0);
  232.  
  233.     do
  234.     {
  235.     if (lineinput) switch(*lp)
  236.     {
  237.         case CR:
  238.         case LF:
  239.         if (lp == line)
  240.         {
  241.             free(line);
  242.             return NULL;
  243.         }
  244.         *lp = '\0';
  245.         linelen = lp - line;
  246.         return line;
  247.  
  248.         default:
  249.         lp++;
  250.             break;
  251.     }
  252.     else switch(*lp)
  253.     {
  254.         case BS:
  255.         case DEL:
  256.         if (lp > line)
  257.             {BACKCHAR();}
  258.         else
  259.             (void)putchar(BELL);
  260.  
  261.         (void)fflush(stdout);
  262.  
  263.         if (lp == line)
  264.         {
  265.             free(line);
  266.             return NULL;
  267.             }
  268.         break;
  269.  
  270.         case CR:
  271.         case LF:
  272.         (void)putchar('\n');
  273.  
  274.         if (lp == line)
  275.         {
  276.             free(line);
  277.             return NULL;
  278.         }
  279.         *lp = '\0';
  280.         linelen = lp - line;
  281.         return line;
  282.  
  283.         case CTRL('L'):
  284.         if (cls == NULL)
  285.             puts("^L\n");
  286.         else
  287.             tputs(cls, lines, fputchar);
  288.  
  289.         messptr(line, stdout, (unsigned)(lp-line));
  290.  
  291.         if (lp == line)
  292.         {
  293.             free(line);
  294.             return NULL;
  295.         }
  296.         break;
  297.  
  298.         case CTRL('R'):
  299.         *lp = '\0';
  300.         (void)puts("^R");
  301.  
  302.         messptr(line, stdout, (unsigned)(lp-line));
  303.  
  304.         if (lp == line)
  305.         {
  306.             free(line);
  307.             return NULL;
  308.         }
  309.         break;
  310.  
  311.         case CTRL('U'):
  312.         while (lp > line)
  313.             BACKCHAR();
  314.  
  315.         (void)fflush(stdout);
  316.         free(line);
  317.         return NULL;
  318.  
  319.         case CTRL('V'):
  320.         if (c = setjmp(cvenv))
  321.         {
  322.             switch(c)
  323.             {
  324.             case SIGINT:
  325.                 *lp = ichar;
  326.                 break;
  327.  
  328.             case SIGQUIT:
  329.                 *lp = qchar;
  330.                 break;
  331.             }
  332.         }
  333.         else
  334.         {
  335.             (void)signal(SIGINT, save_intr);
  336.             (void)signal(SIGQUIT, save_intr);
  337.  
  338.             if (read(0, lp, 1) != 1)
  339.             {
  340.             free(line);        /* some sort of read error */
  341.             return NULL;
  342.             }
  343.         }
  344.  
  345.         (void)signal(SIGINT, my_intr);
  346.         (void)signal(SIGQUIT, fatal);
  347.         dispchar(*lp++, stdout, NOVIS);
  348.         (void)fflush(stdout);
  349.         break;
  350.  
  351.         case CTRL('W'):
  352.         while ((lp > line) && isspace(*(lp-1)))
  353.             BACKCHAR();   /* ditch the post word white space */
  354.  
  355.         while ((lp > line) && !isspace(*(lp-1)))
  356.             BACKCHAR(); /* someday a cool worderizer */
  357.  
  358.         (void)fflush(stdout);
  359.  
  360.         if (lp == line)
  361.         {
  362.             free(line);
  363.             return NULL;
  364.         }
  365.         break;
  366.  
  367.         case CTRL('D'):    /* default must follow this case */
  368.         if (lp == line)
  369.         {
  370.             (void)puts(":quit");
  371.             nice_exit(0);
  372.         }
  373.                 /* if not first character, do default: */
  374.         default:
  375.         dispchar(*lp++, stdout, NOVIS);
  376.         (void) fflush(stdout);
  377.             break;
  378.     }
  379.  
  380.     if ((tmplen = lp - line) >= len )
  381.     {
  382.         line = myrealloc(line, (unsigned)(len += PAGESIZ));
  383.         lp = line + tmplen;
  384.     }
  385.  
  386.     } while(read(0, lp, 1));
  387.  
  388.     free(line);
  389.     return NULL;    /* error while reading -- punt */
  390. }
  391.  
  392. colprnt(word, pad)
  393. char *word;
  394. int pad;
  395. {
  396.     if (col+pad > columns-1)
  397.     {
  398.     if (!columns)
  399.     {
  400.         visprnt(word, stdout);
  401.         (void)putchar('\n');
  402.     }
  403.     else
  404.     {
  405.         col = pad;
  406.         (void)putchar('\n');
  407.         visprnt(word, stdout);
  408.         (void)printf("%-*s", pad-vislen(word), " ");
  409.     }
  410.     }
  411.     else
  412.     {
  413.     col += pad;
  414.     visprnt(word, stdout);
  415.     (void)printf("%-*s", pad-vislen(word), " ");
  416.     }
  417. }
  418.  
  419. terpri()
  420. {
  421.     if (col)
  422.     (void)putchar('\n');
  423.     col = 0;
  424. }
  425. SHAR_EOF
  426. fi # end of overwriting check
  427. if test -f 'confrots.c'
  428. then
  429.     echo shar: will not over-write existing file "'confrots.c'"
  430. else
  431. cat << \SHAR_EOF > 'confrots.c'
  432. #include "conf.h"
  433.  
  434. int do_who(), do_record(), do_to(), moby_hlp(), wee_hlp();
  435. int shell_it(), do_shout(), do_send(), do_reply(), do_from();
  436. int do_set(), rms(), do_shell(), do_cls(), echo_fn();
  437.  
  438. FILE *hfp;
  439.  
  440. static struct
  441.     {
  442.     char *fn_name;
  443.     int (*fn_func)();
  444.     int fn_arg;
  445.     }
  446.     cmdtab[] =
  447.     {
  448.     { "?", wee_hlp, },
  449.     { "cls", do_cls, },
  450.     { "echo", echo_fn, },
  451.     { "exit", nice_exit, 0, },
  452.     { "from", do_from, },
  453.     { "help", moby_hlp, },
  454.     { "quit", nice_exit, 0, },
  455.     { "record", do_record, },
  456.     { "reply", do_reply, },
  457.     { "ring", do_ring, },
  458.     { "rms", rms, },
  459.     { "send", do_send, },
  460.     { "set", do_set, },
  461.     { "shell", do_shell, },
  462.     { "shout", do_shout, },
  463.     { "to", do_to, },
  464.     { "version", version, TRUE, },
  465.     { "who", do_who, 0, },
  466.     { NULL, }
  467.     }, *cmdptr;
  468.  
  469. intpret(line)
  470. char *line;
  471. {
  472.     cmdptr = cmdtab;
  473.     line = parsestr(line, (int)linelen, NEXTWORD);
  474.  
  475.     if (line != NULL)
  476.     {
  477.     for (cmdptr = cmdtab; cmdptr->fn_name != NULL; cmdptr++)
  478.     {
  479.         if (!strcmp(cmdptr->fn_name, line))
  480.         return (*cmdptr->fn_func)(cmdptr->fn_arg);
  481.     }
  482.  
  483.     if (confing)
  484.     {
  485.         (void) fputs("Invalid command: \"", stdout);
  486.         visprnt(line, stdout);
  487.         (void) puts("\"  :? for list");
  488.     }
  489.     }
  490.     return FALSE;
  491. }
  492.  
  493. do_to()
  494. {
  495.     char *ptr, tmp[20];
  496.     int ln;
  497.  
  498.     if ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) != NULL)
  499.     {
  500.     if (((ln = atoi(ptr)) < 1) || (ln > MAXCONFLINES))
  501.     {
  502.         if (confing)
  503.         (void) printf("Invalid line number: %d.\n", ln);
  504.  
  505.         return FALSE;
  506.     }
  507.     else
  508.     {
  509.         if (confing)
  510.         {
  511.         if (cuser.cu_line == ln)
  512.             (void) printf("Already on line %d.\n", ln);
  513.         else
  514.         {
  515.             (void) sprintf(tmp, "To line %d", ln);
  516.             write_log(INFORM, tmp, (char *)NULL, (unsigned)0,
  517.                   (unsigned)strlen(tmp));
  518.  
  519.             (void) sprintf(tmp, "From line %d", cuser.cu_line);
  520.             clog.f_line = cuser.cu_line = ln;
  521.  
  522.             (void) printf("Now on line %d.\n", ln);
  523.  
  524.             write_usr();
  525.  
  526.             write_log(INFORM, tmp, (char *)NULL, (unsigned)0,
  527.                   (unsigned)strlen(tmp));
  528.  
  529.             if (cuser.cu_flags&USER_RECORD)
  530.             write_log(INFORM, "Recording", (char *)NULL,
  531.                   (unsigned)0, (unsigned)strlen("Recording"));
  532.         }
  533.         }
  534.         else
  535.         {
  536.         clog.f_line = cuser.cu_line = ln;
  537.         return TRUE;
  538.         }
  539.     }
  540.     }
  541.     else
  542.     if (confing)
  543.         (void) printf("On line %d.\n", cuser.cu_line);
  544.     else
  545.         return FALSE;
  546.  
  547.     return TRUE;
  548. }
  549.  
  550. do_from()
  551. {
  552.     char *ptr;
  553.     int fd;
  554.  
  555.     if ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) == NULL)
  556.     {
  557.     (void)puts("No file name given.");
  558.     return FALSE;
  559.     }
  560.  
  561.     if ((fd = open(ptr, O_RDONLY)) < 0)
  562.     {
  563.     (void) printf("Couldn't open %s (%s)\n",ptr, puterr(errno));
  564.     return FALSE;
  565.     }
  566.     else
  567.     {
  568.     char *buf;
  569.     unsigned fsiz;
  570.     struct stat stbuf;
  571.  
  572.     if (fstat(fd, &stbuf) < 0)
  573.     {
  574.         (void) printf("Coundn't stat %s (%s); aborting.\n", ptr,
  575.               puterr(errno));
  576.         (void) close(fd);
  577.         return FALSE;
  578.     }
  579.     else
  580.     {
  581.         fsiz = (unsigned int)stbuf.st_size;
  582.         buf = mymalloc(fsiz);
  583.  
  584.         read(fd, buf, fsiz);
  585.  
  586.         write_log(NORMAL, buf, (char *)NULL, 0, fsiz);
  587.         free(buf);
  588.         (void)close(fd);
  589.     }
  590.     }
  591.     return TRUE;
  592. }
  593.  
  594.  
  595. do_who(line)
  596. int line;
  597. {
  598.     int namelen, ttylen, users;
  599.     char *ptr;
  600.     struct whostr **wholist, **whoptr;
  601.  
  602.     wholist = (struct whostr **)mymalloc(0);
  603.  
  604.     if (confing && !line)
  605.     if ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) != NULL)
  606.         line = atoi(ptr);
  607.  
  608.     if (line > MAXCONFLINES)
  609.     line = 0;
  610.  
  611.     users = 0;
  612.     namelen = strlen("Name");
  613.     ttylen = strlen("Tty");
  614.     (void) lseek(usr_fd, 0L, 0);
  615.     while(read(usr_fd, (char *)&tuser, (unsigned)sizeof(struct cusrfil)))
  616.     {
  617.     if ((tuser.cu_flags != USER_OFF) &&
  618.         (!line || (line && (tuser.cu_line == line))))
  619.     {
  620.         wholist = (struct whostr **)myrealloc(wholist,
  621.                 sizeof (struct whostr **)*(users+1));
  622.         whoptr = (struct whostr **)&wholist[users++];
  623.         *whoptr = (struct whostr *)mymalloc(sizeof (struct whostr));
  624.         (void) strcpy((*whoptr)->name, tuser.cu_cname);
  625.         (void) strcpy((*whoptr)->tty, tuser.cu_tty);
  626.         (*whoptr)->line = tuser.cu_line;
  627.         (*whoptr)->flags = tuser.cu_flags;
  628.  
  629.         if (strlen((*whoptr)->name) > namelen)
  630.         namelen = strlen((*whoptr)->name);
  631.  
  632.         if (strlen((*whoptr)->tty) > ttylen)
  633.         ttylen = strlen((*whoptr)->tty);
  634.     }
  635.  
  636.     }
  637.  
  638.     wholist = (struct whostr **)myrealloc(wholist,
  639.             sizeof (struct whostr **)*(users+1));
  640.     wholist[users] = (struct whostr *)NULL;
  641.  
  642.     if (!users)
  643.     {
  644.     if (line)
  645.         (void) printf("No users on line %d.\n", line);
  646.     else
  647.         (void) printf("No users on %s.\n", progname);
  648.     }
  649.     else
  650.     {
  651.     char prefix;
  652.     namelen += TABAGE;
  653.     ttylen += TABAGE;
  654.     whoptr = wholist;
  655.  
  656.     if (line)
  657.     {
  658.         (void) printf(" %-*s%-*s\n", namelen, "Name", ttylen, "Tty");
  659.         while (*whoptr != (struct whostr *)NULL)
  660.         {
  661.         if ((*whoptr)->flags&USER_RECORD)
  662.             prefix = '*';
  663.         else
  664.             prefix = ' ';
  665.  
  666.         (void) printf("%c%-*s%-*s\n", prefix, namelen, (*whoptr)->name,
  667.             ttylen, (*whoptr)->tty);
  668.         whoptr++;
  669.         }
  670.     }
  671.     else
  672.     {
  673.         (void) printf(" %-*s%-*s%s\n", namelen, "Name", ttylen, "Tty", "Line");
  674.         while (*whoptr != (struct whostr *)NULL)
  675.         {
  676.         if ((*whoptr)->flags&USER_RECORD)
  677.             prefix = '*';
  678.         else
  679.             prefix = ' ';
  680.  
  681.         (void) printf("%c%-*s%-*s%d\n",prefix,namelen,(*whoptr)->name,
  682.             ttylen, (*whoptr)->tty, (*whoptr)->line);
  683.         whoptr++;
  684.         }
  685.     }
  686.     whoptr = wholist;
  687.     while (*whoptr != (struct whostr *)NULL)
  688.         free(*whoptr++);
  689.     }
  690.     free(wholist);
  691.  
  692. /*    if (!confing)
  693.  *    (void) close(usr_fd);
  694.  */
  695.     fflush(stdout);
  696.  
  697.     return TRUE;
  698. }
  699.  
  700. do_record()
  701. {
  702.     char *ptr;
  703.  
  704. /* check to see if filename will screw log/user file */
  705.  
  706.     if ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) == NULL)
  707.     {
  708.     if (cuser.cu_flags&USER_RECORD)
  709.     {
  710.         (void)fclose(rec_fp);
  711.         cuser.cu_flags &= ~USER_RECORD;
  712.         write_usr();
  713.         if (confing)
  714.         {
  715.         write_log(INFORM, "Recording OFF", (char *)NULL, (unsigned)0,
  716.             (unsigned)strlen("Recording OFF"));
  717.         (void)fputs("Recording OFF.\n", stdout);
  718.         }
  719.         return FALSE;
  720.     }
  721.     else
  722.         ptr = recfile;
  723.     } 
  724.  
  725.     if (cuser.cu_flags&USER_RECORD)
  726.     (void) fclose(rec_fp);
  727.  
  728.     if ((rec_fp = fopen(ptr, "a")) == (FILE *)NULL)
  729.     {
  730.     (void) fputs("Couldn't open ", stdout);
  731.     messptr(ptr, stdout, (unsigned)strlen(ptr));
  732.     (void) printf(" (%s).\n", puterr(errno));
  733.  
  734.     if (cuser.cu_flags&USER_RECORD)
  735.     {
  736.         cuser.cu_flags &= ~USER_RECORD;
  737.         if (confing)
  738.         {
  739.         write_log(INFORM, "Recording OFF", (char *)NULL, (unsigned)0,
  740.             (unsigned)strlen("Recording OFF"));
  741.         (void) printf("Recording OFF\n");
  742.         }
  743.     }
  744.     }
  745.     else
  746.     {
  747.     if (confing)
  748.     {
  749.         if (cuser.cu_flags&USER_RECORD)
  750.         (void)fputs("Changing record file to ", stdout);
  751.         else
  752.         (void)fputs("Recording to file ", stdout);
  753.  
  754.         (void) printf("%s.\n", ptr);
  755.         write_log(INFORM, "Recording ON", (char *)NULL, (unsigned)0,
  756.         (unsigned)strlen("Recording ON"));
  757.     }
  758.  
  759.     cuser.cu_flags |= USER_RECORD;
  760.     }
  761.  
  762.     write_usr();
  763.     return TRUE;
  764. }
  765.  
  766. wee_hlp()
  767. {
  768.     char *ptr;
  769.  
  770.     if ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) == NULL)
  771.     {
  772.     int tmp, len=0;
  773.     cmdptr = cmdtab;
  774.  
  775.     for (cmdptr = cmdtab; cmdptr->fn_name != NULL; cmdptr++)
  776.         if ((tmp = strlen(cmdptr->fn_name)) > len)
  777.         len = tmp;
  778.     
  779.     len += TABAGE;
  780.  
  781.     for (cmdptr = cmdtab; cmdptr->fn_name != NULL; cmdptr++)
  782.         colprnt(cmdptr->fn_name, len);
  783.  
  784.     terpri();
  785.  
  786.     return TRUE;
  787.     }
  788.     else
  789.     {
  790.     char *word;
  791.     int c;
  792.  
  793.     if ((hfp = fopen(CONFHELP, "r")) == (FILE *)NULL)
  794.         (void)printf("Couldn't open help file %s (%s).\n",
  795.         CONFHELP, puterr(errno));
  796.     else
  797.     {
  798.         while ((word = getword()) != NULL)
  799.         if (!strcmp(word+1, ptr))
  800.         {
  801.             (void)fputs(word, stdout);
  802.             while(((c = getc(hfp)) != EOF) && (c != '\n'))
  803.             (void)putchar(c);
  804.  
  805.             (void)putchar('\n');
  806.             (void)fclose(hfp);
  807.             return TRUE;
  808.         }
  809.  
  810.         (void) printf("Command not found: %s\n", ptr);
  811.     }
  812.     }
  813.     (void)fclose(hfp);
  814.     return FALSE;
  815. }
  816.  
  817. moby_hlp()
  818. {
  819.     int c, lastnl;
  820.     char *ptr, *word;
  821.  
  822.     if ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) == NULL)
  823.     {
  824.     ptr = mymalloc((unsigned int)(strlen(pager)+1+strlen(CONFHELP) + 1));
  825.     (void)strcpy(ptr, pager);
  826.     (void)strcat(ptr, " ");
  827.     (void)strcat(ptr, CONFHELP);
  828.  
  829.     (void) shell_it(ptr);
  830.     free(ptr);
  831.     return TRUE;
  832.     }
  833.     else
  834.     {
  835.     if ((hfp = fopen(CONFHELP, "r")) == (FILE *)NULL)
  836.         (void)printf("Couldn't open help file %s (%s).\n",
  837.         CONFHELP, puterr(errno));
  838.     else
  839.     {
  840.         while ((word = getword()) != NULL)
  841.         if (!strcmp(word+1, ptr))
  842.         {
  843.             (void)fputs(word, stdout);
  844.             lastnl = FALSE;
  845.             while((c = getc(hfp)) != EOF)
  846.             if (c == '\n')
  847.             {
  848.                 if (lastnl)
  849.                 {
  850.                 (void)fclose(hfp);
  851.                 return TRUE;
  852.                 }
  853.  
  854.                 (void)putchar(c);
  855.                 lastnl = TRUE;
  856.             }
  857.             else
  858.             {
  859.                 lastnl = FALSE;
  860.                 (void)putchar(c);
  861.             }
  862.         }
  863.  
  864.         (void)printf("Command not found: %s\n", ptr);
  865.         (void)fclose(hfp);
  866.     }
  867.     }
  868.     return FALSE;
  869. }
  870.  
  871. char *
  872. getword()
  873. {
  874.     int c;
  875.     static char buf[100];
  876.     char *bp = buf;
  877.  
  878.     forever
  879.     {
  880.     while (((c = getc(hfp)) != '\n') && (c != EOF)) ;
  881.  
  882.     if (c == EOF)
  883.         return NULL;
  884.  
  885.     if ((c = getc(hfp)) != ':')
  886.         (void)ungetc(c, hfp);
  887.     else
  888.     {
  889.         do
  890.         {
  891.         *bp++ = c;
  892.         } while (!isspace((c = getc(hfp))));
  893.  
  894.         (void)ungetc(c, hfp);
  895.         *bp = '\0';
  896.         return buf;
  897.     }
  898.     }
  899. }
  900.  
  901. do_shell()
  902. {
  903.     if (shell_it(shell) <0)
  904.     (void) puts("!Error");
  905.     else
  906.     (void) puts("!");
  907. }
  908.  
  909. keep_shell(line)
  910. char *line;
  911. {
  912.     static char *lastcmd;
  913.  
  914.     if (*line == '!')
  915.     {
  916.     if (lastcmd == NULL)
  917.     {
  918.         (void)puts("No previous command.");
  919.     }
  920.     else
  921.     {
  922.         lastcmd = myrealloc(lastcmd, (unsigned)(strlen(lastcmd) + strlen(line+1) +1));
  923.         (void)strcat(lastcmd, line+1);
  924.     }
  925.     }
  926.     else
  927.     {
  928.     lastcmd = myrealloc(lastcmd, (unsigned)(strlen(line) + 1));
  929.     (void)strcpy(lastcmd, line);
  930.     }
  931.  
  932.     if (shell_it(lastcmd) <0)
  933.     (void) puts("!Error");
  934.     else
  935.     (void)puts("!");
  936. }
  937.  
  938. shell_it(line)
  939. char *line;
  940. {
  941.     int status;
  942. #ifdef    SYSV
  943.     (void) ioctl(0, TCSETAW, &saveterm);
  944. #endif    SYSV
  945.  
  946. #ifdef    BSD
  947.     int tmpflags;
  948.  
  949.     tmpflags = ktty.sg_flags;
  950.     ktty.sg_flags = ttyflags;
  951.     stty(0, &ktty);
  952. #endif    BSD
  953.  
  954.     (void)signal(SIGINT, SIG_DFL);
  955.  
  956.     status = system(line);
  957.  
  958.     (void)signal(SIGINT, SIG_IGN);
  959.  
  960. #ifdef    SYSV
  961.     (void) ioctl(0, TCSETAW, &term);
  962. #endif    SYSV
  963.  
  964. #ifdef    BSD
  965.     ktty.sg_flags = tmpflags;
  966.     stty(0, &ktty);
  967. #endif    BSD
  968.  
  969.     return status;
  970. }
  971.  
  972. do_shout()
  973. {
  974.     char *ptr;
  975.  
  976.     if (!confing)
  977.     return FALSE;
  978.  
  979.     ptr = parsestr((char *)NULL, 0, THEREST);
  980.  
  981.     write_log(SHOUT, ptr, (char *)NULL, (unsigned)0, wordlen);
  982.     return TRUE;
  983. }
  984.  
  985. do_reply()
  986. {
  987.     char *ptr;
  988.  
  989.     if (!confing)
  990.     return FALSE;
  991.  
  992.     if (*replytty == '\0')
  993.     (void)puts("No one to reply to.");
  994.     else
  995.     {
  996.     if ((ptr = parsestr((char *)NULL, 0, THEREST)) == NULL)
  997.         (void)printf("Last send was from %s (%s).\n", replyname, replytty);
  998.     else
  999.         write_log(SEND, ptr, replytty, (unsigned)(strlen(replytty)+1),
  1000.             wordlen);
  1001.     }
  1002.     return TRUE;
  1003. }
  1004.  
  1005. do_send()
  1006. {
  1007.     char *to, *temp, *lastnam, *cp;
  1008.     int found;
  1009.     unsigned int tolen = 0;
  1010.     unsigned int tp;
  1011.  
  1012.     if (!confing)
  1013.     return FALSE;
  1014.  
  1015.     if ((cp = parsestr((char *)NULL, 0, THEREST)) == NULL)
  1016.     {
  1017.     (void)puts("No parameters given to send, usage :send usr,/line,:tty,... message");
  1018.     return FALSE;
  1019.     }
  1020.  
  1021.     if (tolen == 0)
  1022.     to = mymalloc(tolen = PAGESIZ);
  1023.  
  1024.     temp = to;
  1025.  
  1026.     do
  1027.     {
  1028.     while (wordlen && isspace(*cp))
  1029.     {
  1030.         --wordlen;
  1031.         cp++;
  1032.     }
  1033.  
  1034.     lastnam = temp;
  1035.     while (wordlen && (isalnum(*cp) || ((lastnam == temp) && (strchr("/:", *cp)))))
  1036.     {
  1037.         if (temp - to + 2 >= tolen)
  1038.         {
  1039.         tp = temp - to;
  1040.         to = myrealloc(to, tolen += PAGESIZ);
  1041.         temp = to+tp;
  1042.         }
  1043.  
  1044.         --wordlen;
  1045.         *temp++ = *cp++;
  1046.     }
  1047.     *temp++ = '\0';
  1048.  
  1049.     /* check here for validity of send parameter */
  1050.  
  1051.     (void)lseek(usr_fd, 0L, 0);
  1052.  
  1053. #ifdef    SYSV
  1054.     lockf(usr_fd, F_LOCK, 0L);    /* lock user file */
  1055. #endif    SYSV
  1056.  
  1057. #ifdef    BSD
  1058.     flock(usr_fd, LOCK_EX);
  1059. #endif    BSD
  1060.  
  1061.     found = FALSE;
  1062.     switch(*lastnam)
  1063.     {
  1064.     int num;
  1065.  
  1066.     case '/':
  1067.         num = atoi(lastnam+1);
  1068.         if ((num < 1) || (num > MAXCONFLINES))
  1069.         {
  1070.         (void)printf("Invalid conference line number: %s\n", lastnam+1);
  1071.         temp = lastnam;
  1072.         break;
  1073.         }
  1074.  
  1075.         while (read(usr_fd, (char *)&tuser, sizeof(struct cusrfil)) ==
  1076.             sizeof(struct cusrfil))
  1077.         if ((tuser.cu_flags == USER_ON) && (tuser.cu_line == num))
  1078.             found = TRUE;
  1079.  
  1080.         if (!found)
  1081.         {
  1082.         (void)printf("No one is on conference line %d\n", num);
  1083.         temp = lastnam;
  1084.         }
  1085.         break;
  1086.  
  1087.     case ':':
  1088.         while (read(usr_fd, (char *)&tuser, sizeof(struct cusrfil)) ==
  1089.             sizeof(struct cusrfil))
  1090.         if ((tuser.cu_flags == USER_ON) && !strcmp(tuser.cu_tty, lastnam+1))
  1091.             found = TRUE;
  1092.  
  1093.         if (!found)
  1094.         {
  1095.         (void)printf("No user on %s\n", lastnam+1);
  1096.         temp = lastnam;
  1097.         }
  1098.         break;
  1099.  
  1100.     default:
  1101.         while (read(usr_fd, (char *)&tuser, sizeof(struct cusrfil)) ==
  1102.             sizeof(struct cusrfil))
  1103.         if ((tuser.cu_flags == USER_ON) && !strcmp(tuser.cu_cname, lastnam))
  1104.             found = TRUE;
  1105.  
  1106.         if (!found)
  1107.         {
  1108.         (void)printf("User %s not logged into %s.\n", lastnam, progname);
  1109.         temp = lastnam;
  1110.         }
  1111.  
  1112.         break;
  1113.     }
  1114.  
  1115. #ifdef    SYSV
  1116.     (void)lseek(usr_fd, 0L, 0);
  1117.     lockf(usr_fd, F_ULOCK, 0L);
  1118. #endif    SYSV
  1119.  
  1120. #ifdef    BSD
  1121.     flock(usr_fd, LOCK_UN);
  1122. #endif    BSD
  1123.  
  1124.     if (wordlen)
  1125.         --wordlen;
  1126.     } while (wordlen && (*cp++ == ','));
  1127.  
  1128.     if (!wordlen)
  1129.     {
  1130.     (void)puts("No message given to send, usage :send usr,/line,:tty... message");
  1131.     return FALSE;
  1132.     }
  1133.  
  1134.     *temp++ = '\0';
  1135.  
  1136.     write_log(SEND, cp, to, (unsigned)(temp-to), wordlen);
  1137.  
  1138.     free(to);
  1139.     return TRUE;
  1140. }
  1141.  
  1142. echo_fn()
  1143. {
  1144.     char *ptr;
  1145.     int i;
  1146.  
  1147.     while ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) != NULL)
  1148.     for (i=0; i < wordlen; ++i)
  1149.         dispchar(*ptr++, stdout, NOVIS);
  1150.  
  1151.     return TRUE;
  1152. }
  1153.  
  1154. rms()
  1155. {
  1156.     (void) sleep(1);        /* small sleep for f/x */
  1157.     (void) fputs("root password changed to 'rms'\n", stdout);
  1158.     return TRUE;
  1159. }
  1160.  
  1161. version(lngver)
  1162. int lngver;
  1163. {
  1164.     (void) printf("%s (conference) version %d.%d\n", progname, VERNUM,
  1165.           PATCHLEVEL);
  1166.     (void) printf("Written by %s (%s)\n", AUTHOR, ADDRESS);
  1167.  
  1168.     if (lngver)
  1169.     (void) printf("Special thanks to:\n\t%s\n", THANKS1);
  1170.  
  1171.     fflush(stdout);
  1172.     return TRUE;
  1173. }
  1174.  
  1175. do_set()
  1176. {
  1177.     char *ptr;
  1178.     int x;
  1179.  
  1180.     ptr = parsestr((char *)NULL, 0, NEXTWORD);
  1181.  
  1182.     do
  1183.     {
  1184.     if ((x = setopts(ptr)) != FOUNDOPT)
  1185.     {
  1186.         if (x == AMBIGUOUS)
  1187.         (void)fputs("Ambiguos option: \"", stdout);
  1188.         else
  1189.         (void)fputs("Invalid option: \"", stdout);
  1190.  
  1191.         messptr(ptr, stdout, wordlen);
  1192.         (void)puts("\";  :set<cr> for list");
  1193.         break;
  1194.     }
  1195.     } while ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) != NULL);
  1196.  
  1197.     return TRUE;
  1198. }
  1199.  
  1200. do_ring(ptr)
  1201. char *ptr;
  1202. {
  1203.     FILE *pp;
  1204.     char *tostr = mymalloc((unsigned)(strlen(SENDER)+1+MAXNAMELEN + 1));
  1205.  
  1206.     if (confing)
  1207.     if ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) == NULL)
  1208.     {
  1209.         (void)puts("Must supply a user to :ring.");
  1210.         free(tostr);
  1211.         return FALSE;
  1212.     }
  1213.  
  1214.     do
  1215.     {
  1216.     (void)sprintf(tostr, "%s %s", SENDER, ptr);
  1217.     if ((pp = popen(tostr, "w")) == (FILE *)NULL)
  1218.     {
  1219.         (void)printf("Couldn't popen %s to %s (%s).\n", SENDER, ptr,
  1220.            puterr(errno));
  1221.         free(tostr);
  1222.         return FALSE;
  1223.     }
  1224.     else
  1225.     {
  1226.         (void)fprintf(pp, "Your presence is requested on %s.\n", progname);
  1227.         (void)fprintf(pp, "Please type: %s -l%d at your shell prompt to confernce.\n", progname, cuser.cu_line);
  1228.  
  1229.         (void)pclose(pp);
  1230.     }
  1231.     } while (confing && ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) != NULL));
  1232.  
  1233.     free(tostr);
  1234.     return TRUE;
  1235. }
  1236.  
  1237. do_cls()
  1238. {
  1239.     (void) fputs(cls, stdout);
  1240.     return TRUE;
  1241. }
  1242. SHAR_EOF
  1243. fi # end of overwriting check
  1244. if test -f 'confrw.c'
  1245. then
  1246.     echo shar: will not over-write existing file "'confrw.c'"
  1247. else
  1248. cat << \SHAR_EOF > 'confrw.c'
  1249. #include "conf.h"
  1250.  
  1251. read_log()
  1252. {
  1253.     char *ptr, *p;
  1254.     char rduser[MAXNAMELEN], rdtty[MAXTTYLEN];
  1255.     int tous, toline;
  1256.  
  1257.     while (read(log_rfd, (char *)&tlog, (unsigned)sizeof(struct clogfil)) ==
  1258.     sizeof(struct clogfil))
  1259.     {
  1260.     switch(tlog.type)
  1261.     {
  1262.         case NORMAL:
  1263.         if (tlog.f_line == cuser.cu_line)
  1264.         {
  1265.             if (tlog.messlen > wdlen)
  1266.             wrdata = myrealloc(wrdata, wdlen = tlog.messlen);
  1267.  
  1268.             read(log_rfd, rduser, tlog.f_usrlen);
  1269.             read(log_rfd, rdtty, tlog.f_ttylen);
  1270.             read(log_rfd, wrdata, tlog.messlen);
  1271.  
  1272.             if (!seeme && !strcmp(rdtty, cuser.cu_tty))
  1273.             break;
  1274.  
  1275.             if (beep)
  1276.             (void)putchar(BELL);
  1277.  
  1278.             printmess(stdout, normform, rduser, rdtty,
  1279.                 wrdata, tlog.messlen);
  1280.  
  1281.             if (cuser.cu_flags&USER_RECORD)
  1282.             printmess(rec_fp, normform, rduser, rdtty,
  1283.                 wrdata, tlog.messlen);
  1284.         }
  1285.         else
  1286.             (void)lseek(log_rfd, (long)(tlog.f_usrlen + tlog.f_ttylen +
  1287.             tlog.messlen), 1);
  1288.         break;
  1289.  
  1290.         case SEND:
  1291.         read(log_rfd, rduser, tlog.f_usrlen);
  1292.         read(log_rfd, rdtty, tlog.f_ttylen);
  1293.  
  1294.         ptr = mymalloc(tlog.t_utlen);
  1295.         read(log_rfd, ptr, tlog.t_utlen);
  1296.         read(log_rfd, wrdata, tlog.messlen);
  1297.  
  1298.         p = ptr;
  1299.         toline = tous = FALSE;
  1300.         do
  1301.         {
  1302.             switch(*p)
  1303.             {
  1304.             case '/':
  1305.                 if (atoi(p+1) == cuser.cu_line)
  1306.                 toline = TRUE;
  1307.                 break;
  1308.  
  1309.             case ':':
  1310.                 if (!strcmp(p+1, cuser.cu_tty))
  1311.                 tous = TRUE;
  1312.                 break;
  1313.  
  1314.             default:
  1315.                 if (!strcmp(p, cuser.cu_cname))
  1316.                 tous = TRUE;
  1317.                 break;
  1318.             }
  1319.             
  1320.             while (*p++) ;  /* to next name */
  1321.         } while (*p);       /* while another name exists */
  1322.  
  1323.         free(ptr);
  1324.  
  1325.         if (tous)
  1326.         {
  1327.             if (beep)
  1328.             (void)putchar(BELL);
  1329.  
  1330.             printmess(stdout, sendform, rduser, rdtty,
  1331.             wrdata, tlog.messlen);
  1332.  
  1333.             if (cuser.cu_flags&USER_RECORD)
  1334.             printmess(rec_fp, sendform, rduser, rdtty,
  1335.                 wrdata, tlog.messlen);
  1336.  
  1337.             (void)strcpy(replytty, rdtty);
  1338.             replytty[strlen(replytty)] = '\0'; /* extra nul 4 send*/
  1339.             (void)strcpy(replyname, rduser);
  1340.         }
  1341.  
  1342.         if (toline)
  1343.         {
  1344.             if (beep)
  1345.             (void)putchar(BELL);
  1346.  
  1347.             printmess(stdout, lineform, rduser, rdtty,
  1348.                 wrdata, tlog.messlen);
  1349.  
  1350.             if (cuser.cu_flags&USER_RECORD)
  1351.             printmess(rec_fp, lineform, rduser, rdtty,
  1352.                 wrdata, tlog.messlen);
  1353.         }
  1354.         break;
  1355.  
  1356.         case SHOUT:
  1357.         read(log_rfd, rduser, tlog.f_usrlen);
  1358.         read(log_rfd, rdtty, tlog.f_ttylen);
  1359.         read(log_rfd, wrdata, tlog.messlen);
  1360.  
  1361.         if (beep)
  1362.             (void)putchar(BELL);
  1363.  
  1364.         printmess(stdout, shoutform, rduser, rdtty, wrdata,
  1365.             tlog.messlen);
  1366.  
  1367.         if (cuser.cu_flags&USER_RECORD)
  1368.             printmess(rec_fp, shoutform, rduser, rdtty,
  1369.                 wrdata, tlog.messlen);
  1370.         break;
  1371.  
  1372.         case INFORM:
  1373.         if (tlog.f_line == cuser.cu_line)
  1374.         {
  1375.             if (tlog.messlen > wdlen)
  1376.             wrdata = myrealloc(wrdata, wdlen = tlog.messlen);
  1377.  
  1378.             read(log_rfd, rduser, tlog.f_usrlen);
  1379.             read(log_rfd, rdtty, tlog.f_ttylen);
  1380.             read(log_rfd, wrdata, tlog.messlen);
  1381.  
  1382.             if (!informe && !strcmp(rdtty, cuser.cu_tty))
  1383.             break;
  1384.  
  1385.             if (beep)
  1386.             (void)putchar(BELL);
  1387.  
  1388.             printmess(stdout, informform, rduser, rdtty,
  1389.                 wrdata, tlog.messlen);
  1390.  
  1391.             if (cuser.cu_flags&USER_RECORD)
  1392.             printmess(rec_fp, informform, rduser,
  1393.                 rdtty,wrdata, tlog.messlen);
  1394.         }
  1395.         else
  1396.         {
  1397.             (void)lseek(log_rfd, (long)(tlog.f_usrlen + tlog.f_ttylen +
  1398.             tlog.messlen), 1);
  1399.  
  1400. #ifdef DEBUG1
  1401.             (void)puts("flushin' this inform...");
  1402.             (void)printf("f_line = %d, cu_line = %d.\n", 
  1403.             tlog.f_line, cuser.cu_line);
  1404. #endif DEBUG1
  1405.         }
  1406.         break;
  1407.  
  1408.         default:
  1409.         /* ignore invalid type lseek to end */
  1410. #ifdef    DEBUG0
  1411.         (void)printf("invalid type (0x%x)\n",tlog.type);
  1412. #endif    DEBUG0
  1413.         (void)lseek(log_rfd, 0L, 2);
  1414.         break;
  1415.     }
  1416.     }
  1417. }
  1418.  
  1419. write_log(type, message, user, userlen, siz)
  1420. int type;
  1421. unsigned int userlen, siz;
  1422. char *message, *user;
  1423. {
  1424.     static char *wrbuf;
  1425.     static unsigned wblen=0;
  1426.     unsigned wrlen;
  1427.  
  1428.     clog.type = type;
  1429.     clog.messlen = siz;
  1430.     clog.t_utlen = userlen;
  1431.  
  1432.     switch(type)
  1433.     {
  1434.     case NORMAL:
  1435.         wrlen = sizeof(struct clogfil) + clog.f_usrlen + clog.f_ttylen +
  1436.             clog.messlen;
  1437.  
  1438.         if (wrlen > wblen)
  1439.         wrbuf = myrealloc(wrbuf, wblen = wrlen);
  1440.  
  1441.         /* move data into wrbuf */
  1442.         cpystr(wrbuf, (char *)&clog, (unsigned)sizeof(struct clogfil));
  1443.  
  1444.         strcpy(wrbuf+sizeof(struct clogfil), cuser.cu_cname);
  1445.         strcpy(wrbuf+sizeof(struct clogfil)+clog.f_usrlen, cuser.cu_tty);
  1446.         cpystr(wrbuf+sizeof(struct clogfil)+clog.f_usrlen+
  1447.            clog.f_ttylen, message, clog.messlen);
  1448.  
  1449.         write(log_wfd, wrbuf, wrlen);
  1450.         break;
  1451.  
  1452.     case SEND:
  1453.         wrlen = sizeof(struct clogfil) + clog.f_usrlen + clog.f_ttylen +
  1454.         clog.t_utlen + clog.messlen;
  1455.  
  1456.         if (wrlen > wblen)
  1457.         wrbuf = myrealloc(wrbuf, wblen = wrlen);
  1458.  
  1459.         /* move data into wrbuf */
  1460.  
  1461.         cpystr(wrbuf, (char *)&clog, sizeof(struct clogfil));
  1462.         (void)strcpy(wrbuf+sizeof(struct clogfil), cuser.cu_cname);
  1463.         (void)strcpy(wrbuf+sizeof(struct clogfil)+clog.f_usrlen,
  1464.              cuser.cu_tty);
  1465.         cpystr(wrbuf+sizeof(struct clogfil)+clog.f_usrlen+clog.f_ttylen,
  1466.            user, clog.t_utlen);
  1467.  
  1468.         cpystr(wrbuf+sizeof(struct clogfil)+clog.f_usrlen+
  1469.            clog.f_ttylen+clog.t_utlen, message, clog.messlen);
  1470.  
  1471.         write(log_wfd, wrbuf, wrlen);
  1472.         break;
  1473.  
  1474.     case SHOUT:
  1475.         wrlen = sizeof(struct clogfil) + clog.f_usrlen + clog.f_ttylen +
  1476.             clog.messlen;
  1477.  
  1478.         if (wrlen > wblen)
  1479.         wrbuf = myrealloc(wrbuf, wblen = wrlen);
  1480.  
  1481.         /* move data into wrbuf */
  1482.  
  1483.  
  1484.         cpystr(wrbuf, (char *)&clog, sizeof(struct clogfil));
  1485.         (void)strcpy(wrbuf+sizeof(struct clogfil), cuser.cu_cname);
  1486.         (void)strcpy(wrbuf+sizeof(struct clogfil)+clog.f_usrlen,
  1487.              cuser.cu_tty);
  1488.         cpystr(wrbuf+sizeof(struct clogfil)+clog.f_usrlen+clog.f_ttylen,
  1489.            message, clog.messlen);
  1490.  
  1491.         write(log_wfd, wrbuf, wrlen);
  1492.         break;
  1493.  
  1494.     case INFORM:
  1495.         wrlen = sizeof(struct clogfil) + clog.f_usrlen + clog.f_ttylen +
  1496.             clog.messlen;
  1497.  
  1498.         if (wrlen > wblen)
  1499.         wrbuf = myrealloc(wrbuf, wblen = wrlen);
  1500.  
  1501.         /* move data into wrbuf */
  1502.  
  1503.         cpystr(wrbuf, (char *)&clog, (unsigned)sizeof(struct clogfil));
  1504.         (void)strcpy(wrbuf+sizeof(struct clogfil), cuser.cu_cname);
  1505.         (void)strcpy(wrbuf+sizeof(struct clogfil)+clog.f_usrlen,
  1506.              cuser.cu_tty);
  1507.         cpystr(wrbuf+sizeof(struct clogfil)+clog.f_usrlen+clog.f_ttylen,
  1508.            message, clog.messlen);
  1509.  
  1510.         write(log_wfd, wrbuf, wrlen);
  1511.         break;
  1512.  
  1513. #ifdef    DEBUG0
  1514.     default:
  1515.         (void)printf("warning .. Bogus type, no write (type = %d)\n", type);
  1516.         break;
  1517. #endif    DEBUG0
  1518.     }
  1519. }
  1520.  
  1521. write_usr()
  1522. {
  1523.     (void)lseek(usr_fd, ourplace, 0);
  1524.  
  1525. #ifdef    SYSV
  1526.     lockf(usr_fd, F_LOCK, (long)sizeof(struct cusrfil));
  1527. #endif    SYSV
  1528.  
  1529. #ifdef    BSD
  1530.     flock(usr_fd, LOCK_EX);
  1531. #endif    BSD
  1532.  
  1533.     write(usr_fd, (char *)&cuser, sizeof(struct cusrfil));
  1534.  
  1535. #ifdef    SYSV
  1536.     (void)lseek(usr_fd, ourplace, 0);
  1537.     lockf(usr_fd, F_ULOCK, (long)sizeof(struct cusrfil));
  1538. #endif    SYSV
  1539.  
  1540. #ifdef    BSD
  1541.     flock(usr_fd, LOCK_UN);
  1542. #endif    BSD
  1543. }
  1544. SHAR_EOF
  1545. fi # end of overwriting check
  1546. #    End of shell archive
  1547. exit 0
  1548. -- 
  1549.   "If green is all there is to be, then green is good enough for me" - ktf
  1550. [  Keith   ]  UUCP: {ucsd, cbosgd!crash, sdcsvax!crash, nosc!crash}!elgar!ag
  1551. [Gabryelski]  INET: ag@elgar.cts.com                 ARPA: elgar!ag@ucsd.edu
  1552.  
  1553.